using AOT;
using Unity.Burst;

namespace DA.AnimGraph {
    [BurstCompile]
    public unsafe partial struct TimelinePerk {
        public struct SetupData {
            public AUID timelineUuid;
        }

        AUID timelineUuid;

        [BurstCompile]
        static void SetupLink(TimelinePerk* self, PerkLink* link) {
            link->SetupPerk(self);
        }

        void Setup(in SetupData setupData) {
            timelineUuid = setupData.timelineUuid;
        }

        [BurstCompile]
        [MonoPInvokeCallback(typeof(PerkLink.EvaluateDelegate))]
        internal static void Evaluate(in void* ptr, in TimeState* timeState, bool onEnter, in EvaluateContext evaluateContext, in GraphContext graphContext, ref UpstreamData upstream, ref ScopeContext scope) {
            if (timeState != null) {
                var self = (TimelinePerk*)ptr;
                upstream.AddTimelineSlice(self->timelineUuid, timeState, onEnter);
            }
        }

        [BurstCompile]
        [MonoPInvokeCallback(typeof(PerkLink.OnExitDelegate))]
        private static void OnExit(in void* ptr, in TimeState* timeState, ref UpstreamData upstream) {
            var self = (TimelinePerk*)ptr;

            upstream.AddTimelineEndSlice(self->timelineUuid, timeState);
        }
    }
}